home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / winioctl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  33.1 KB  |  875 lines

  1. /*++ BUILD Version: 0013    // Increment this if a change has global effects
  2.  
  3. Copyright (c) 1990-1996  Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     winioctl.h
  8.  
  9. Abstract:
  10.  
  11.     This module defines the 32-Bit Windows Device I/O control codes.
  12.  
  13. Revision History:
  14.  
  15. --*/
  16.  
  17. #ifndef _WINIOCTL_
  18. #define _WINIOCTL_
  19. #pragma option push -b
  20.  
  21. #ifndef _DEVIOCTL_
  22. #define _DEVIOCTL_
  23.  
  24. // begin_ntddk begin_nthal begin_ntifs
  25. //
  26. // Define the various device type values.  Note that values used by Microsoft
  27. // Corporation are in the range 0-32767, and 32768-65535 are reserved for use
  28. // by customers.
  29. //
  30.  
  31. #define DEVICE_TYPE DWORD
  32.  
  33. #define FILE_DEVICE_BEEP                0x00000001
  34. #define FILE_DEVICE_CD_ROM              0x00000002
  35. #define FILE_DEVICE_CD_ROM_FILE_SYSTEM  0x00000003
  36. #define FILE_DEVICE_CONTROLLER          0x00000004
  37. #define FILE_DEVICE_DATALINK            0x00000005
  38. #define FILE_DEVICE_DFS                 0x00000006
  39. #define FILE_DEVICE_DISK                0x00000007
  40. #define FILE_DEVICE_DISK_FILE_SYSTEM    0x00000008
  41. #define FILE_DEVICE_FILE_SYSTEM         0x00000009
  42. #define FILE_DEVICE_INPORT_PORT         0x0000000a
  43. #define FILE_DEVICE_KEYBOARD            0x0000000b
  44. #define FILE_DEVICE_MAILSLOT            0x0000000c
  45. #define FILE_DEVICE_MIDI_IN             0x0000000d
  46. #define FILE_DEVICE_MIDI_OUT            0x0000000e
  47. #define FILE_DEVICE_MOUSE               0x0000000f
  48. #define FILE_DEVICE_MULTI_UNC_PROVIDER  0x00000010
  49. #define FILE_DEVICE_NAMED_PIPE          0x00000011
  50. #define FILE_DEVICE_NETWORK             0x00000012
  51. #define FILE_DEVICE_NETWORK_BROWSER     0x00000013
  52. #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
  53. #define FILE_DEVICE_NULL                0x00000015
  54. #define FILE_DEVICE_PARALLEL_PORT       0x00000016
  55. #define FILE_DEVICE_PHYSICAL_NETCARD    0x00000017
  56. #define FILE_DEVICE_PRINTER             0x00000018
  57. #define FILE_DEVICE_SCANNER             0x00000019
  58. #define FILE_DEVICE_SERIAL_MOUSE_PORT   0x0000001a
  59. #define FILE_DEVICE_SERIAL_PORT         0x0000001b
  60. #define FILE_DEVICE_SCREEN              0x0000001c
  61. #define FILE_DEVICE_SOUND               0x0000001d
  62. #define FILE_DEVICE_STREAMS             0x0000001e
  63. #define FILE_DEVICE_TAPE                0x0000001f
  64. #define FILE_DEVICE_TAPE_FILE_SYSTEM    0x00000020
  65. #define FILE_DEVICE_TRANSPORT           0x00000021
  66. #define FILE_DEVICE_UNKNOWN             0x00000022
  67. #define FILE_DEVICE_VIDEO               0x00000023
  68. #define FILE_DEVICE_VIRTUAL_DISK        0x00000024
  69. #define FILE_DEVICE_WAVE_IN             0x00000025
  70. #define FILE_DEVICE_WAVE_OUT            0x00000026
  71. #define FILE_DEVICE_8042_PORT           0x00000027
  72. #define FILE_DEVICE_NETWORK_REDIRECTOR  0x00000028
  73. #define FILE_DEVICE_BATTERY             0x00000029
  74. #define FILE_DEVICE_BUS_EXTENDER        0x0000002a
  75. #define FILE_DEVICE_MODEM               0x0000002b
  76. #define FILE_DEVICE_VDM                 0x0000002c
  77. #define FILE_DEVICE_MASS_STORAGE        0x0000002d
  78.  
  79. //
  80. // Macro definition for defining IOCTL and FSCTL function control codes.  Note
  81. // that function codes 0-2047 are reserved for Microsoft Corporation, and
  82. // 2048-4095 are reserved for customers.
  83. //
  84.  
  85. #define CTL_CODE( DeviceType, Function, Method, Access ) (                 \
  86.     ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
  87. )
  88.  
  89. //
  90. // Define the method codes for how buffers are passed for I/O and FS controls
  91. //
  92.  
  93. #define METHOD_BUFFERED                 0
  94. #define METHOD_IN_DIRECT                1
  95. #define METHOD_OUT_DIRECT               2
  96. #define METHOD_NEITHER                  3
  97.  
  98. //
  99. // Define the access check value for any access
  100. //
  101. //
  102. // The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in
  103. // ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these
  104. // constants *MUST* always be in sync.
  105. //
  106.  
  107.  
  108. #define FILE_ANY_ACCESS                 0
  109. #define FILE_READ_ACCESS          ( 0x0001 )    // file & pipe
  110. #define FILE_WRITE_ACCESS         ( 0x0002 )    // file & pipe
  111.  
  112. // end_ntddk end_nthal end_ntifs
  113.  
  114. #endif // _DEVIOCTL_
  115.  
  116.  
  117. #ifndef _NTDDSTOR_H_
  118. #define _NTDDSTOR_H_
  119.  
  120.  
  121. //
  122. // IoControlCode values for disk devices.
  123. //
  124.  
  125. #define IOCTL_STORAGE_BASE                FILE_DEVICE_MASS_STORAGE
  126.  
  127. //
  128. // The following device control codes are common for all class drivers.  They
  129. // should be used in place of the older IOCTL_DISK, IOCTL_CDROM and IOCTL_TAPE
  130. // common codes
  131. //
  132.  
  133. #define IOCTL_STORAGE_CHECK_VERIFY     CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
  134. #define IOCTL_STORAGE_MEDIA_REMOVAL    CTL_CODE(IOCTL_STORAGE_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
  135. #define IOCTL_STORAGE_EJECT_MEDIA      CTL_CODE(IOCTL_STORAGE_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
  136. #define IOCTL_STORAGE_LOAD_MEDIA       CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
  137. #define IOCTL_STORAGE_RESERVE          CTL_CODE(IOCTL_STORAGE_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
  138. #define IOCTL_STORAGE_RELEASE          CTL_CODE(IOCTL_STORAGE_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
  139. #define IOCTL_STORAGE_FIND_NEW_DEVICES CTL_CODE(IOCTL_STORAGE_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
  140. #define IOCTL_STORAGE_GET_MEDIA_TYPES  CTL_CODE(IOCTL_STORAGE_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
  141.  
  142. //
  143. // IOCTL_STORAGE_MEDIA_REMOVAL disables the mechanism
  144. // on a storage device that ejects media. This function
  145. // may or may not be supported on storage devices that
  146. // support removable media.
  147. //
  148. // TRUE means prevent media from being removed.
  149. // FALSE means allow media removal.
  150. //
  151.  
  152. typedef struct _PREVENT_MEDIA_REMOVAL {
  153.     BOOLEAN PreventMediaRemoval;
  154. } PREVENT_MEDIA_REMOVAL, *PPREVENT_MEDIA_REMOVAL;
  155.  
  156. #endif // _NTDDSTOR_H_
  157.  
  158. //
  159. // IoControlCode values for disk devices.
  160. //
  161.  
  162. #define IOCTL_DISK_BASE                 FILE_DEVICE_DISK
  163. #define IOCTL_DISK_GET_DRIVE_GEOMETRY   CTL_CODE(IOCTL_DISK_BASE, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS)
  164. #define IOCTL_DISK_GET_PARTITION_INFO   CTL_CODE(IOCTL_DISK_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
  165. #define IOCTL_DISK_SET_PARTITION_INFO   CTL_CODE(IOCTL_DISK_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  166. #define IOCTL_DISK_GET_DRIVE_LAYOUT     CTL_CODE(IOCTL_DISK_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
  167. #define IOCTL_DISK_SET_DRIVE_LAYOUT     CTL_CODE(IOCTL_DISK_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  168. #define IOCTL_DISK_VERIFY               CTL_CODE(IOCTL_DISK_BASE, 0x0005, METHOD_BUFFERED, FILE_ANY_ACCESS)
  169. #define IOCTL_DISK_FORMAT_TRACKS        CTL_CODE(IOCTL_DISK_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  170. #define IOCTL_DISK_REASSIGN_BLOCKS      CTL_CODE(IOCTL_DISK_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  171. #define IOCTL_DISK_PERFORMANCE          CTL_CODE(IOCTL_DISK_BASE, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS)
  172. #define IOCTL_DISK_IS_WRITABLE          CTL_CODE(IOCTL_DISK_BASE, 0x0009, METHOD_BUFFERED, FILE_ANY_ACCESS)
  173. #define IOCTL_DISK_LOGGING              CTL_CODE(IOCTL_DISK_BASE, 0x000a, METHOD_BUFFERED, FILE_ANY_ACCESS)
  174. #define IOCTL_DISK_FORMAT_TRACKS_EX     CTL_CODE(IOCTL_DISK_BASE, 0x000b, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  175. #define IOCTL_DISK_HISTOGRAM_STRUCTURE  CTL_CODE(IOCTL_DISK_BASE, 0x000c, METHOD_BUFFERED, FILE_ANY_ACCESS)
  176. #define IOCTL_DISK_HISTOGRAM_DATA       CTL_CODE(IOCTL_DISK_BASE, 0x000d, METHOD_BUFFERED, FILE_ANY_ACCESS)
  177. #define IOCTL_DISK_HISTOGRAM_RESET      CTL_CODE(IOCTL_DISK_BASE, 0x000e, METHOD_BUFFERED, FILE_ANY_ACCESS)
  178. #define IOCTL_DISK_REQUEST_STRUCTURE    CTL_CODE(IOCTL_DISK_BASE, 0x000f, METHOD_BUFFERED, FILE_ANY_ACCESS)
  179. #define IOCTL_DISK_REQUEST_DATA         CTL_CODE(IOCTL_DISK_BASE, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS)
  180.  
  181. #if(_WIN32_WINNT >= 0x0400)
  182. #define IOCTL_DISK_CONTROLLER_NUMBER    CTL_CODE(IOCTL_DISK_BASE, 0x0011, METHOD_BUFFERED, FILE_ANY_ACCESS)
  183.  
  184. //
  185. // IOCTL support for SMART drive fault prediction.
  186. //
  187.  
  188. #define SMART_GET_VERSION               CTL_CODE(IOCTL_DISK_BASE, 0x0020, METHOD_BUFFERED, FILE_READ_ACCESS)
  189. #define SMART_SEND_DRIVE_COMMAND        CTL_CODE(IOCTL_DISK_BASE, 0x0021, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  190. #define SMART_RCV_DRIVE_DATA            CTL_CODE(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  191. #endif /* _WIN32_WINNT >= 0x0400 */
  192.  
  193. //
  194. //  These are special IOCTLs needed to support PC-98 machines in Japan
  195. //
  196.  
  197. #define IOCTL_DISK_GET_DRIVE_LAYOUT_NEC  CTL_CODE(IOCTL_DISK_BASE, 0x00f1, METHOD_BUFFERED, FILE_READ_ACCESS)
  198. #define IOCTL_DISK_SET_DRIVE_LAYOUT_NEC  CTL_CODE(IOCTL_DISK_BASE, 0x00f2, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  199. #define IOCTL_DISK_FORMAT_DRIVE          CTL_CODE(IOCTL_DISK_BASE, 0x00f3, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  200. #define IOCTL_DISK_SET_MEDIA_TYPE        CTL_CODE(IOCTL_DISK_BASE, 0x00f4, METHOD_BUFFERED, FILE_ANY_ACCESS)
  201. #define IOCTL_DISK_READ                  CTL_CODE(IOCTL_DISK_BASE, 0x00f5, METHOD_IN_DIRECT, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  202. #define IOCTL_DISK_WRITE                 CTL_CODE(IOCTL_DISK_BASE, 0x00f6, METHOD_OUT_DIRECT, FILE_WRITE_ACCESS)
  203. #define IOCTL_DISK_GET_STATUS            CTL_CODE(IOCTL_DISK_BASE, 0x00f7, METHOD_BUFFERED, FILE_ANY_ACCESS)
  204. #define IOCTL_DISK_SENSE_DEVICE          CTL_CODE(IOCTL_DISK_BASE, 0x00f8, METHOD_BUFFERED, FILE_ANY_ACCESS)
  205. #define IOCTL_DISK_GET_REMOVABLE_TYPES   CTL_CODE(IOCTL_DISK_BASE, 0x00fa, METHOD_BUFFERED, FILE_READ_ACCESS)
  206. #define IOCTL_DISK_ARRAY                 CTL_CODE(IOCTL_DISK_BASE, 0x00fb, METHOD_IN_DIRECT, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  207. #define IOCTL_DISK_ARRAY_SENSE           CTL_CODE(IOCTL_DISK_BASE, 0x00fc, METHOD_IN_DIRECT, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  208. #define IOCTL_DISK_SENSE_DATA            CTL_CODE(IOCTL_DISK_BASE, 0x00fd, METHOD_IN_DIRECT, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  209.  
  210. //
  211. // The following device control codes are common for all class drivers.  The
  212. // functions codes defined here must match all of the other class drivers.
  213. //
  214. // Warning: these codes will be replaced in the future by equivalent
  215. // IOCTL_STORAGE codes
  216. //
  217.  
  218. #define IOCTL_DISK_CHECK_VERIFY     CTL_CODE(IOCTL_DISK_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
  219. #define IOCTL_DISK_MEDIA_REMOVAL    CTL_CODE(IOCTL_DISK_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
  220. #define IOCTL_DISK_EJECT_MEDIA      CTL_CODE(IOCTL_DISK_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
  221. #define IOCTL_DISK_LOAD_MEDIA       CTL_CODE(IOCTL_DISK_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
  222. #define IOCTL_DISK_RESERVE          CTL_CODE(IOCTL_DISK_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
  223. #define IOCTL_DISK_RELEASE          CTL_CODE(IOCTL_DISK_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
  224. #define IOCTL_DISK_FIND_NEW_DEVICES CTL_CODE(IOCTL_DISK_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
  225. #define IOCTL_DISK_GET_MEDIA_TYPES CTL_CODE(IOCTL_DISK_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
  226.  
  227. //
  228. // Define the partition types returnable by known disk drivers.
  229. //
  230.  
  231. #define PARTITION_ENTRY_UNUSED          0x00      // Entry unused
  232. #define PARTITION_FAT_12                0x01      // 12-bit FAT entries
  233. #define PARTITION_XENIX_1               0x02      // Xenix
  234. #define PARTITION_XENIX_2               0x03      // Xenix
  235. #define PARTITION_FAT_16                0x04      // 16-bit FAT entries
  236. #define PARTITION_EXTENDED              0x05      // Extended partition entry
  237. #define PARTITION_HUGE                  0x06      // Huge partition MS-DOS V4
  238. #define PARTITION_IFS                   0x07      // IFS Partition
  239. #define PARTITION_FAT32                 0x0B      // FAT32
  240. #define PARTITION_FAT32_XINT13          0x0C      // FAT32 using extended int13 services
  241. #define PARTITION_XINT13                0x0E      // Win95 partition using extended int13 services
  242. #define PARTITION_XINT13_EXTENDED       0x0F      // Same as type 5 but uses extended int13 services
  243. #define PARTITION_PREP                  0x41      // PowerPC Reference Platform (PReP) Boot Partition
  244. #define PARTITION_UNIX                  0x63      // Unix
  245.  
  246. #define VALID_NTFT                      0xC0      // NTFT uses high order bits
  247.  
  248. //
  249. // The high bit of the partition type code indicates that a partition
  250. // is part of an NTFT mirror or striped array.
  251. //
  252.  
  253. #define PARTITION_NTFT                  0x80     // NTFT partition
  254.  
  255. //
  256. // The following macro is used to determine which partitions should be
  257. // assigned drive letters.
  258. //
  259.  
  260. //++
  261. //
  262. // BOOLEAN
  263. // IsRecognizedPartition(
  264. //     IN DWORD PartitionType
  265. //     )
  266. //
  267. // Routine Description:
  268. //
  269. //     This macro is used to determine to which partitions drive letters
  270. //     should be assigned.
  271. //
  272. // Arguments:
  273. //
  274. //     PartitionType - Supplies the type of the partition being examined.
  275. //
  276. // Return Value:
  277. //
  278. //     The return value is TRUE if the partition type is recognized,
  279. //     otherwise FALSE is returned.
  280. //
  281. //--
  282.  
  283. #define IsRecognizedPartition( PartitionType ) (       \
  284.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT_12)) ||  \
  285.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT_16)) ||  \
  286.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_IFS)) ||  \
  287.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_HUGE)) ||  \
  288.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT32)) ||  \
  289.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT32_XINT13)) ||  \
  290.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_XINT13)) ||  \
  291.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT_12) ||  \
  292.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT_16) ||  \
  293.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_IFS)    ||  \
  294.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_HUGE)    ||  \
  295.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT32)  || \
  296.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT32_XINT13) || \
  297.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_XINT13) )
  298.  
  299. //++
  300. //
  301. // BOOLEAN
  302. // IsContainerPartition(
  303. //     IN DWORD PartitionType
  304. //     )
  305. //
  306. // Routine Description:
  307. //
  308. //     This macro is used to determine to which partition types are actually
  309. //     containers for other partitions (ie, extended partitions).
  310. //
  311. // Arguments:
  312. //
  313. //     PartitionType - Supplies the type of the partition being examined.
  314. //
  315. // Return Value:
  316. //
  317. //     The return value is TRUE if the partition type is a container,
  318. //     otherwise FALSE is returned.
  319. //
  320. //--
  321.  
  322. #define IsContainerPartition( PartitionType ) \
  323.     ((PartitionType == PARTITION_EXTENDED) || (PartitionType == PARTITION_XINT13_EXTENDED))
  324.  
  325. //
  326. // Define the media types supported by the driver.
  327. //
  328.  
  329. typedef enum _MEDIA_TYPE {
  330.     Unknown,                // Format is unknown
  331.     F5_1Pt2_512,            // 5.25", 1.2MB,  512 bytes/sector
  332.     F3_1Pt44_512,           // 3.5",  1.44MB, 512 bytes/sector
  333.     F3_2Pt88_512,           // 3.5",  2.88MB, 512 bytes/sector
  334.     F3_20Pt8_512,           // 3.5",  20.8MB, 512 bytes/sector
  335.     F3_720_512,             // 3.5",  720KB,  512 bytes/sector
  336.     F5_360_512,             // 5.25", 360KB,  512 bytes/sector
  337.     F5_320_512,             // 5.25", 320KB,  512 bytes/sector
  338.     F5_320_1024,            // 5.25", 320KB,  1024 bytes/sector
  339.     F5_180_512,             // 5.25", 180KB,  512 bytes/sector
  340.     F5_160_512,             // 5.25", 160KB,  512 bytes/sector
  341.     RemovableMedia,         // Removable media other than floppy
  342.     FixedMedia,             // Fixed hard disk media
  343.     F3_120M_512,            // 3.5", 120M Floppy
  344.     F3_640_512,             // 3.5" ,  640KB,  512 bytes/sector
  345.     F5_640_512,             // 5.25",  640KB,  512 bytes/sector
  346.     F5_720_512,             // 5.25",  720KB,  512 bytes/sector
  347.     F3_1Pt2_512,            // 3.5" ,  1.2Mb,  512 bytes/sector
  348.     F3_1Pt23_1024,          // 3.5" ,  1.23Mb, 1024 bytes/sector
  349.     F5_1Pt23_1024,          // 5.25",  1.23MB, 1024 bytes/sector
  350.     F3_128Mb_512,           // 3.5" MO 128Mb   512 bytes/sector
  351.     F3_230Mb_512,           // 3.5" MO 230Mb   512 bytes/sector
  352.     F8_256_128              // 8",     256KB,  128 bytes/sector
  353. } MEDIA_TYPE, *PMEDIA_TYPE;
  354.  
  355. //
  356. // Define the input buffer structure for the driver, when
  357. // it is called with IOCTL_DISK_FORMAT_TRACKS.
  358. //
  359.  
  360. typedef struct _FORMAT_PARAMETERS {
  361.    MEDIA_TYPE MediaType;
  362.    DWORD StartCylinderNumber;
  363.    DWORD EndCylinderNumber;
  364.    DWORD StartHeadNumber;
  365.    DWORD EndHeadNumber;
  366. } FORMAT_PARAMETERS, *PFORMAT_PARAMETERS;
  367.  
  368. //
  369. // Define the BAD_TRACK_NUMBER type. An array of elements of this type is
  370. // returned by the driver on IOCTL_DISK_FORMAT_TRACKS requests, to indicate
  371. // what tracks were bad during formatting. The length of that array is
  372. // reported in the `Information' field of the I/O Status Block.
  373. //
  374.  
  375. typedef WORD   BAD_TRACK_NUMBER;
  376. typedef WORD   *PBAD_TRACK_NUMBER;
  377.  
  378. //
  379. // Define the input buffer structure for the driver, when
  380. // it is called with IOCTL_DISK_FORMAT_TRACKS_EX.
  381. //
  382.  
  383. typedef struct _FORMAT_EX_PARAMETERS {
  384.    MEDIA_TYPE MediaType;
  385.    DWORD StartCylinderNumber;
  386.    DWORD EndCylinderNumber;
  387.    DWORD StartHeadNumber;
  388.    DWORD EndHeadNumber;
  389.    WORD   FormatGapLength;
  390.    WORD   SectorsPerTrack;
  391.    WORD   SectorNumber[1];
  392. } FORMAT_EX_PARAMETERS, *PFORMAT_EX_PARAMETERS;
  393.  
  394. //
  395. // The following structure is returned on an IOCTL_DISK_GET_DRIVE_GEOMETRY
  396. // request and an array of them is returned on an IOCTL_DISK_GET_MEDIA_TYPES
  397. // request.
  398. //
  399.  
  400. typedef struct _DISK_GEOMETRY {
  401.     LARGE_INTEGER Cylinders;
  402.     MEDIA_TYPE MediaType;
  403.     DWORD TracksPerCylinder;
  404.     DWORD SectorsPerTrack;
  405.     DWORD BytesPerSector;
  406. } DISK_GEOMETRY, *PDISK_GEOMETRY;
  407.  
  408. //
  409. // The following structure is returned on an IOCTL_DISK_GET_PARTITION_INFO
  410. // and an IOCTL_DISK_GET_DRIVE_LAYOUT request.  It is also used in a request
  411. // to change the drive layout, IOCTL_DISK_SET_DRIVE_LAYOUT.
  412. //
  413.  
  414. typedef struct _PARTITION_INFORMATION {
  415.     LARGE_INTEGER StartingOffset;
  416.     LARGE_INTEGER PartitionLength;
  417.     DWORD HiddenSectors;
  418.     DWORD PartitionNumber;
  419.     BYTE  PartitionType;
  420.     BOOLEAN BootIndicator;
  421.     BOOLEAN RecognizedPartition;
  422.     BOOLEAN RewritePartition;
  423. } PARTITION_INFORMATION, *PPARTITION_INFORMATION;
  424.  
  425. typedef struct _PARTITION_INFORMATION_NEC {
  426.     BYTE  PartitionType;
  427.     BOOLEAN RecognizedPartition;
  428.     BOOLEAN RewritePartition;
  429.     DWORD PartitionNumber;
  430.     LARGE_INTEGER IplStartOffset;
  431.     LARGE_INTEGER StartingOffset;
  432.     LARGE_INTEGER PartitionLength;
  433.     BYTE  BootableFlag;
  434.     BYTE  PartitionName[16];
  435. } PARTITION_INFORMATION_NEC, *PPARTITION_INFORMATION_NEC;
  436.  
  437. //
  438. // The following structure is used to change the partition type of a
  439. // specified disk partition using an IOCTL_DISK_SET_PARTITION_INFO
  440. // request.
  441. //
  442.  
  443. typedef struct _SET_PARTITION_INFORMATION {
  444.     BYTE  PartitionType;
  445. } SET_PARTITION_INFORMATION, *PSET_PARTITION_INFORMATION;
  446.  
  447. //
  448. // The following structures is returned on an IOCTL_DISK_GET_DRIVE_LAYOUT
  449. // request and given as input to an IOCTL_DISK_SET_DRIVE_LAYOUT request.
  450. //
  451.  
  452. typedef struct _DRIVE_LAYOUT_INFORMATION {
  453.     DWORD PartitionCount;
  454.     DWORD Signature;
  455.     PARTITION_INFORMATION PartitionEntry[1];
  456. } DRIVE_LAYOUT_INFORMATION, *PDRIVE_LAYOUT_INFORMATION;
  457.  
  458. typedef struct _DRIVE_LAYOUT_INFORMATION_5MO {
  459.     DWORD PartitionCount;
  460.     DWORD Signature;
  461.     PARTITION_INFORMATION PartitionEntry[4];
  462. } DRIVE_LAYOUT_INFORMATION_5MO, *PDRIVE_LAYOUT_INFORMATION_5MO;
  463.  
  464. //
  465. // The following structures is returned on an IOCTL_DISK_GET_DRIVE_LAYOUT_NEC
  466. // request and given as input to an IOCTL_DISK_SET_DRIVE_LAYOUT_NEC request.
  467. //
  468.  
  469. typedef struct _DRIVE_LAYOUT_INFORMATION_NEC {
  470.     DWORD PartitionCount;
  471.     DWORD Signature;
  472.     BYTE  BootRecordNec[8];
  473.     PARTITION_INFORMATION_NEC PartitionEntry[1];
  474. } DRIVE_LAYOUT_INFORMATION_NEC, *PDRIVE_LAYOUT_INFORMATION_NEC;
  475.  
  476. //
  477. // The following structures is passed in an IOCTL_DISK_FORMAT_DRIVE
  478. // request
  479. //
  480.  
  481. typedef struct _PHYSICAL_FORMAT_DRIVE {
  482.     DWORD FormatDriveSize;
  483. } FORMAT_DRIVE_PARAMETERS,*PFORMAT_DRIVE_PARAMETERS;
  484.  
  485. //
  486. // The following structure is passed in on an IOCTL_DISK_VERIFY request.
  487. // The offset and length parameters are both given in bytes.
  488. //
  489.  
  490. typedef struct _VERIFY_INFORMATION {
  491.     LARGE_INTEGER StartingOffset;
  492.     DWORD Length;
  493. } VERIFY_INFORMATION, *PVERIFY_INFORMATION;
  494.  
  495. //
  496. // The following structure is passed in on an IOCTL_DISK_REASSIGN_BLOCKS
  497. // request.
  498. //
  499.  
  500. typedef struct _REASSIGN_BLOCKS {
  501.     WORD   Reserved;
  502.     WORD   Count;
  503.     DWORD BlockNumber[1];
  504. } REASSIGN_BLOCKS, *PREASSIGN_BLOCKS;
  505.  
  506. #if(_WIN32_WINNT >= 0x0400)
  507. //
  508. // IOCTL_DISK_CONTROLLER_NUMBER returns the controller and disk
  509. // number for the handle.  This is used to determine if a disk
  510. // is attached to the primary or secondary IDE controller.
  511. //
  512.  
  513. typedef struct _DISK_CONTROLLER_NUMBER {
  514.     DWORD ControllerNumber;
  515.     DWORD DiskNumber;
  516. } DISK_CONTROLLER_NUMBER, *PDISK_CONTROLLER_NUMBER;
  517. #endif /* _WIN32_WINNT >= 0x0400 */
  518.  
  519. ///////////////////////////////////////////////////////
  520. //                                                   //
  521. // The following structures define disk performance  //
  522. // statistics: specifically the locations of all the //
  523. // reads and writes which have occured on the disk.  //
  524. //                                                   //
  525. // To use these structures, you must issue an IOCTL_ //
  526. // DISK_HIST_STRUCTURE (with a DISK_HISTOGRAM) to    //
  527. // obtain the basic histogram information. The       //
  528. // number of buckets which must allocated is part of //
  529. // this structure. Allocate the required number of   //
  530. // buckets and call an IOCTL_DISK_HIST_DATA to fill  //
  531. // in the data                                       //
  532. //                                                   //
  533. ///////////////////////////////////////////////////////
  534.  
  535. #define HIST_NO_OF_BUCKETS  24
  536.  
  537. typedef struct _HISTOGRAM_BUCKET {
  538.     DWORD       Reads;
  539.     DWORD       Writes;
  540. } HISTOGRAM_BUCKET, *PHISTOGRAM_BUCKET;
  541.  
  542. #define HISTOGRAM_BUCKET_SIZE   sizeof(HISTOGRAM_BUCKET)
  543.  
  544. typedef struct _DISK_HISTOGRAM {
  545.     LARGE_INTEGER   DiskSize;
  546.     LARGE_INTEGER   Start;
  547.     LARGE_INTEGER   End;
  548.     LARGE_INTEGER   Average;
  549.     LARGE_INTEGER   AverageRead;
  550.     LARGE_INTEGER   AverageWrite;
  551.     DWORD           Granularity;
  552.     DWORD           Size;
  553.     DWORD           ReadCount;
  554.     DWORD           WriteCount;
  555.     PHISTOGRAM_BUCKET  Histogram;
  556. } DISK_HISTOGRAM, *PDISK_HISTOGRAM;
  557.  
  558. #define DISK_HISTOGRAM_SIZE sizeof(DISK_HISTOGRAM)
  559.  
  560. ///////////////////////////////////////////////////////
  561. //                                                   //
  562. // The following structures define disk debugging    //
  563. // capabilities. The IOCTLs are directed to one of   //
  564. // the two disk filter drivers.                      //
  565. //                                                   //
  566. // DISKPERF is a utilty for collecting disk request  //
  567. // statistics.                                       //
  568. //                                                   //
  569. // SIMBAD is a utility for injecting faults in       //
  570. // IO requests to disks.                             //
  571. //                                                   //
  572. ///////////////////////////////////////////////////////
  573.  
  574. //
  575. // The following structure is exchanged on an IOCTL_DISK_GET_PERFORMANCE
  576. // request. This ioctl collects summary disk request statistics used
  577. // in measuring performance.
  578. //
  579.  
  580. typedef struct _DISK_PERFORMANCE {
  581.         LARGE_INTEGER BytesRead;
  582.         LARGE_INTEGER BytesWritten;
  583.         LARGE_INTEGER ReadTime;
  584.         LARGE_INTEGER WriteTime;
  585.         DWORD ReadCount;
  586.         DWORD WriteCount;
  587.         DWORD QueueDepth;
  588. } DISK_PERFORMANCE, *PDISK_PERFORMANCE;
  589.  
  590. //
  591. // This structure defines the disk logging record. When disk logging
  592. // is enabled, one of these is written to an internal buffer for each
  593. // disk request.
  594. //
  595.  
  596. typedef struct _DISK_RECORD {
  597.    LARGE_INTEGER ByteOffset;
  598.    LARGE_INTEGER StartTime;
  599.    LARGE_INTEGER EndTime;
  600.    PVOID VirtualAddress;
  601.    DWORD NumberOfBytes;
  602.    BYTE  DeviceNumber;
  603.    BOOLEAN ReadRequest;
  604. } DISK_RECORD, *PDISK_RECORD;
  605.  
  606. //
  607. // The following structure is exchanged on an IOCTL_DISK_LOG request.
  608. // Not all fields are valid with each function type.
  609. //
  610.  
  611. typedef struct _DISK_LOGGING {
  612.     BYTE  Function;
  613.     PVOID BufferAddress;
  614.     DWORD BufferSize;
  615. } DISK_LOGGING, *PDISK_LOGGING;
  616.  
  617. //
  618. // Disk logging functions
  619. //
  620. // Start disk logging. Only the Function and BufferSize fields are valid.
  621. //
  622.  
  623. #define DISK_LOGGING_START    0
  624.  
  625. //
  626. // Stop disk logging. Only the Function field is valid.
  627. //
  628.  
  629. #define DISK_LOGGING_STOP     1
  630.  
  631. //
  632. // Return disk log. All fields are valid. Data will be copied from internal
  633. // buffer to buffer specified for the number of bytes requested.
  634. //
  635.  
  636. #define DISK_LOGGING_DUMP     2
  637.  
  638. //
  639. // DISK BINNING
  640. //
  641. // DISKPERF will keep counters for IO that falls in each of these ranges.
  642. // The application determines the number and size of the ranges.
  643. // Joe Lin wanted me to keep it flexible as possible, for instance, IO
  644. // sizes are interesting in ranges like 0-4096, 4097-16384, 16385-65536, 65537+.
  645. //
  646.  
  647. #define DISK_BINNING          3
  648.  
  649. //
  650. // Bin types
  651. //
  652.  
  653. typedef enum _BIN_TYPES {
  654.     RequestSize,
  655.     RequestLocation
  656. } BIN_TYPES;
  657.  
  658. //
  659. // Bin ranges
  660. //
  661.  
  662. typedef struct _BIN_RANGE {
  663.     LARGE_INTEGER StartValue;
  664.     LARGE_INTEGER Length;
  665. } BIN_RANGE, *PBIN_RANGE;
  666.  
  667. //
  668. // Bin definition
  669. //
  670.  
  671. typedef struct _PERF_BIN {
  672.     DWORD NumberOfBins;
  673.     DWORD TypeOfBin;
  674.     BIN_RANGE BinsRanges[1];
  675. } PERF_BIN, *PPERF_BIN ;
  676.  
  677. //
  678. // Bin count
  679. //
  680.  
  681. typedef struct _BIN_COUNT {
  682.     BIN_RANGE BinRange;
  683.     DWORD BinCount;
  684. } BIN_COUNT, *PBIN_COUNT;
  685.  
  686. //
  687. // Bin results
  688. //
  689.  
  690. typedef struct _BIN_RESULTS {
  691.     DWORD NumberOfBins;
  692.     BIN_COUNT BinCounts[1];
  693. } BIN_RESULTS, *PBIN_RESULTS;
  694.  
  695. #if(_WIN32_WINNT >= 0x0400)
  696. //
  697. // Data structures for SMART drive fault prediction.
  698. //
  699. // GETVERSIONINPARAMS contains the data returned from the
  700. // Get Driver Version function.
  701. //
  702.  
  703. #pragma pack(1)
  704. typedef struct _GETVERSIONINPARAMS {
  705.         BYTE     bVersion;               // Binary driver version.
  706.         BYTE     bRevision;              // Binary driver revision.
  707.         BYTE     bReserved;              // Not used.
  708.         BYTE     bIDEDeviceMap;          // Bit map of IDE devices.
  709.         DWORD   fCapabilities;          // Bit mask of driver capabilities.
  710.         DWORD   dwReserved[4];          // For future use.
  711. } GETVERSIONINPARAMS, *PGETVERSIONINPARAMS, *LPGETVERSIONINPARAMS;
  712. #pragma pack()
  713.  
  714. //
  715. // Bits returned in the fCapabilities member of GETVERSIONINPARAMS
  716. //
  717.  
  718. #define CAP_ATA_ID_CMD          1       // ATA ID command supported
  719. #define CAP_ATAPI_ID_CMD        2       // ATAPI ID command supported
  720. #define CAP_SMART_CMD           4       // SMART commannds supported
  721.  
  722. //
  723. // IDE registers
  724. //
  725.  
  726. #pragma pack(1)
  727. typedef struct _IDEREGS {
  728.         BYTE     bFeaturesReg;           // Used for specifying SMART "commands".
  729.         BYTE     bSectorCountReg;        // IDE sector count register
  730.         BYTE     bSectorNumberReg;       // IDE sector number register
  731.         BYTE     bCylLowReg;             // IDE low order cylinder value
  732.         BYTE     bCylHighReg;            // IDE high order cylinder value
  733.         BYTE     bDriveHeadReg;          // IDE drive/head register
  734.         BYTE     bCommandReg;            // Actual IDE command.
  735.         BYTE     bReserved;                      // reserved for future use.  Must be zero.
  736. } IDEREGS, *PIDEREGS, *LPIDEREGS;
  737. #pragma pack()
  738.  
  739. //
  740. // Valid values for the bCommandReg member of IDEREGS.
  741. //
  742.  
  743. #define ATAPI_ID_CMD    0xA1            // Returns ID sector for ATAPI.
  744. #define ID_CMD          0xEC            // Returns ID sector for ATA.
  745. #define SMART_CMD       0xB0            // Performs SMART cmd.
  746.                                         // Requires valid bFeaturesReg,
  747.                                         // bCylLowReg, and bCylHighReg
  748.  
  749. //
  750. // Cylinder register defines for SMART command
  751. //
  752.  
  753. #define SMART_CYL_LOW   0x4F
  754. #define SMART_CYL_HI    0xC2
  755.  
  756.  
  757. //
  758. // SENDCMDINPARAMS contains the input parameters for the
  759. // Send Command to Drive function.
  760. //
  761.  
  762. #pragma pack(1)
  763. typedef struct _SENDCMDINPARAMS {
  764.         DWORD   cBufferSize;            // Buffer size in bytes
  765.         IDEREGS irDriveRegs;            // Structure with drive register values.
  766.         BYTE     bDriveNumber;           // Physical drive number to send
  767.                                                                 // command to (0,1,2,3).
  768.         BYTE     bReserved[3];           // Reserved for future expansion.
  769.         DWORD   dwReserved[4];          // For future use.
  770.         BYTE     bBuffer[1];                     // Input buffer.
  771. } SENDCMDINPARAMS, *PSENDCMDINPARAMS, *LPSENDCMDINPARAMS;
  772. #pragma pack()
  773.  
  774. //
  775. // Status returned from driver
  776. //
  777.  
  778. #pragma pack(1)
  779. typedef struct _DRIVERSTATUS {
  780.         BYTE     bDriverError;           // Error code from driver,
  781.                                                                 // or 0 if no error.
  782.         BYTE     bIDEError;                      // Contents of IDE Error register.
  783.                                                                 // Only valid when bDriverError
  784.                                                                 // is SMART_IDE_ERROR.
  785.         BYTE     bReserved[2];           // Reserved for future expansion.
  786.         DWORD   dwReserved[2];          // Reserved for future expansion.
  787. } DRIVERSTATUS, *PDRIVERSTATUS, *LPDRIVERSTATUS;
  788. #pragma pack()
  789.  
  790. //
  791. // bDriverError values
  792. //
  793.  
  794. #define SMART_NO_ERROR          0       // No error
  795. #define SMART_IDE_ERROR         1       // Error from IDE controller
  796. #define SMART_INVALID_FLAG      2       // Invalid command flag
  797. #define SMART_INVALID_COMMAND   3       // Invalid command byte
  798. #define SMART_INVALID_BUFFER    4       // Bad buffer (null, invalid addr..)
  799. #define SMART_INVALID_DRIVE     5       // Drive number not valid
  800. #define SMART_INVALID_IOCTL     6       // Invalid IOCTL
  801. #define SMART_ERROR_NO_MEM      7       // Could not lock user's buffer
  802. #define SMART_INVALID_REGISTER  8       // Some IDE Register not valid
  803. #define SMART_NOT_SUPPORTED     9       // Invalid cmd flag set
  804. #define SMART_NO_IDE_DEVICE     10      // Cmd issued to device not present
  805.                                         // although drive number is valid
  806.  
  807. #pragma pack(1)
  808. typedef struct _SENDCMDOUTPARAMS {
  809.         DWORD                   cBufferSize;            // Size of bBuffer in bytes
  810.         DRIVERSTATUS            DriverStatus;           // Driver status structure.
  811.         BYTE                    bBuffer[1];             // Buffer of arbitrary length in which to store the data read from the                                                                                  // drive.
  812. } SENDCMDOUTPARAMS, *PSENDCMDOUTPARAMS, *LPSENDCMDOUTPARAMS;
  813. #pragma pack()
  814.  
  815.  
  816. #define READ_ATTRIBUTE_BUFFER_SIZE  512
  817. #define IDENTIFY_BUFFER_SIZE        512
  818. #define READ_THRESHOLD_BUFFER_SIZE  512
  819.  
  820. //
  821. // Feature register defines for SMART "sub commands"
  822. //
  823.  
  824. #define READ_ATTRIBUTES         0xD0
  825. #define READ_THRESHOLDS         0xD1
  826. #define ENABLE_DISABLE_AUTOSAVE 0xD2
  827. #define SAVE_ATTRIBUTE_VALUES   0xD3
  828. #define EXECUTE_OFFLINE_DIAGS   0xD4
  829. #define ENABLE_SMART            0xD8
  830. #define DISABLE_SMART           0xD9
  831. #define RETURN_SMART_STATUS     0xDA
  832. #endif /* _WIN32_WINNT >= 0x0400 */
  833.  
  834.  
  835.  
  836. #define IOCTL_SERIAL_LSRMST_INSERT      CTL_CODE(FILE_DEVICE_SERIAL_PORT,31,METHOD_BUFFERED,FILE_ANY_ACCESS)
  837.  
  838.  
  839. //
  840. // The following values follow the escape designator in the
  841. // data stream if the LSRMST_INSERT mode has been turned on.
  842. //
  843. #define SERIAL_LSRMST_ESCAPE     ((BYTE )0x00)
  844.  
  845. //
  846. // Following this value is the contents of the line status
  847. // register, and then the character in the RX hardware when
  848. // the line status register was encountered.
  849. //
  850. #define SERIAL_LSRMST_LSR_DATA   ((BYTE )0x01)
  851.  
  852. //
  853. // Following this value is the contents of the line status
  854. // register.  No error character follows
  855. //
  856. #define SERIAL_LSRMST_LSR_NODATA ((BYTE )0x02)
  857.  
  858. //
  859. // Following this value is the contents of the modem status
  860. // register.
  861. //
  862. #define SERIAL_LSRMST_MST        ((BYTE )0x03)
  863.  
  864. #define FSCTL_LOCK_VOLUME               CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
  865. #define FSCTL_UNLOCK_VOLUME             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
  866. #define FSCTL_DISMOUNT_VOLUME           CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
  867. #define FSCTL_MOUNT_DBLS_VOLUME         CTL_CODE(FILE_DEVICE_FILE_SYSTEM,13, METHOD_BUFFERED, FILE_ANY_ACCESS)
  868. #define FSCTL_GET_COMPRESSION           CTL_CODE(FILE_DEVICE_FILE_SYSTEM,15, METHOD_BUFFERED, FILE_ANY_ACCESS)
  869. #define FSCTL_SET_COMPRESSION           CTL_CODE(FILE_DEVICE_FILE_SYSTEM,16, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
  870. #define FSCTL_READ_COMPRESSION          CTL_CODE(FILE_DEVICE_FILE_SYSTEM,17, METHOD_NEITHER,  FILE_READ_DATA)
  871. #define FSCTL_WRITE_COMPRESSION         CTL_CODE(FILE_DEVICE_FILE_SYSTEM,18, METHOD_NEITHER,  FILE_WRITE_DATA)
  872.  
  873. #pragma option pop
  874. #endif // _WINIOCTL_
  875.